package com.moli.iov.down.command.codec.encode.data;

import com.moli.iov.down.model.dto.remoting.CommandDto;
import org.apache.commons.lang.ArrayUtils;

/**
 * <p>
 *  远程车辆控制命令数据编码  0xD1
 * </p>
 *
 * @author: zql
 * @Date: 2018/11/27 16:36
 */
public class ControlDataEncoder extends BaseEncoder implements DataEncoder {

    @Override
    public byte[] encode(CommandDto commandDto){
        byte[] all = getByteBuf(commandDto);

        //控制命令
        byte[] command = {commandDto.getControlCommand()};
        all = ArrayUtils.addAll(all, command);

        //控制内容
        byte[] controlContentByteArray = {commandDto.getControlContent()};

        return ArrayUtils.addAll(all, controlContentByteArray);
    }

}
